﻿using System;
using System.Text;
using System.Data;

using LTJ.Common.Generic;
using LTJ.Entity;
using LTJ.Common;
using LTJ.Config;

namespace LTJ.Data.DataProvider
{
    /// <summary>
    /// 静态统计操作
    /// </summary>
    public class Statics
    {
        /// <summary>
        /// 根据企业ID获取企业统计信息
        /// </summary>
        public static StaticInfo GetStaticInfoByCid(int cid)
        {
            return LoadSingleStaticInfo(DatabaseProvider.GetInstance().GetStaticInfoByCid(cid));
        }

        private static StaticInfo LoadSingleStaticInfo(IDataReader reader)
        {
            StaticInfo sinfo = null;

            if (reader.Read())
            {
                sinfo = new StaticInfo();
                sinfo.managercount = TypeConverter.ObjectToInt(reader["managercount"], 0);
                sinfo.managerlogins = TypeConverter.ObjectToInt(reader["managerlogins"], 0);
                sinfo.nowmanagers = TypeConverter.ObjectToInt(reader["nowmanagers"], 0);
                sinfo.nowusers = TypeConverter.ObjectToInt(reader["nowusers"], 0);
                sinfo.usercount = TypeConverter.ObjectToInt(reader["usercount"], 0);
                sinfo.userlogins = TypeConverter.ObjectToInt(reader["userlogins"], 0);
                sinfo.yesnewroutes = TypeConverter.ObjectToInt(reader["yesnewroutes"], 0);
                sinfo.yesnotes = TypeConverter.ObjectToInt(reader["yesnotes"], 0);
                sinfo.passtime = TypeConverter.ObjectToInt(reader["passtime"], 0);
            }
            reader.Close();
            return sinfo;
        }
    }
}
